package com.sicheng.algorithm.recursive;

import java.util.Arrays;

import static com.sicheng.algorithm.common.Sort.swap;

/**
 * @author zsc
 * @version 1.0
 * @date 2021/9/24 21:27
 */
public class Permutation {
    public static void main(String[] args) {

        permutation("12345");
    }

    public static void permutation(String content) {
        if (content == null || content.length() == 0)
            return;

        permutation(content.toCharArray(), 0);
    }

    public static void permutation(char[] chars, int layer) {
        if (layer == chars.length) {
            System.out.println(Arrays.toString(chars));
        } else {
            for (int i = layer; i < chars.length; i++) {
                swap(chars, i, layer);
                permutation(chars, layer + 1);
                swap(chars, i, layer);
            }

        }


    }
}
